package com.qaml.mes.device.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qaml.mes.device.dao.CheckUpkeepRecordItemDO;
import com.qaml.mes.device.dao.mapper.CheckUpkeepRecordItemMapper;
import com.qaml.mes.device.repository.CheckUpkeepRecordItemRepository;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 检保记录条目表 服务实现类
 * </p>
 *
 * @author leikai
 * @since 2024-02-28
 */
@Repository
public class CheckUpkeepRecordItemRepositoryImpl implements CheckUpkeepRecordItemRepository {


    @Resource
    private CheckUpkeepRecordItemMapper mapper;

    @Override
    public void saveBatch(List<CheckUpkeepRecordItemDO> checkUpkeepRecordsList) {
        mapper.saveBatch(checkUpkeepRecordsList);
    }

    /**
     * 根据检保任务id查询
     *
     * @param checkUpkeepRecordId
     * @return
     */
    @Override
    public List<CheckUpkeepRecordItemDO> getByCheckUpkeepRecordId(String checkUpkeepRecordId) {
        LambdaQueryWrapper<CheckUpkeepRecordItemDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(CheckUpkeepRecordItemDO::getCheckUpkeepRecordId, checkUpkeepRecordId);
        lambdaQueryWrapper.eq(CheckUpkeepRecordItemDO::getIsDeleted, 0);
        return mapper.selectList(lambdaQueryWrapper);
    }

    @Override
    public void updateStatusByRecordId(String id) {
        mapper.updateStatusByRecordId(id);
    }

    @Override
    public void updateBatch(List<CheckUpkeepRecordItemDO> checkUpkeepRecordItemDOS) {
        checkUpkeepRecordItemDOS.forEach(item -> {
            mapper.updateById(item);
        });
    }

}
